home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / net / netware / nwbindry.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-20  |  51.3 KB  |  1,374 lines

  1. {$X+,B-,V-}
  2.  
  3. UNIT nwBindry;
  4.  
  5. INTERFACE
  6.  
  7. USES nwMisc;
  8.  
  9. { Primary Functions:                    Interrupt: comments:
  10.  
  11. * AddBinderyObjectToSet                 (F217/41)
  12. * ChangeBinderyObjectPassword           (F217/40) Unencrypted Passwords.
  13.   ChangeEncrBinderyObjectPassword       (F217/4B) Encrypted Passwords.
  14. * ChangeBinderyObjectSecurity           (F217/38)
  15. - ChangePassword                        (F217/01) #2
  16. * ChangePropertySecurity                (F217/3B)
  17. * CloseBindery                          (F217/44)
  18. * CreateBinderyObject                   (F217/32)
  19. * CreateProperty                        (F217/39)
  20. * DeleteBinderyObject                   (F217/33)
  21. * DeleteBinderyObjectFromSet            (F217/42)
  22. * DeleteProperty                        (F217/3A)
  23. * GetBinderyAccessLevel                 (F217/46)
  24. * GetBinderyObjectID                    (F217/35)
  25. * GetBinderyObjectName                  (F217/36)
  26. - GetMemberSetMofGroupG                 (F217/09) #6
  27. * IsBinderyObjectInSet                  (F217/43)
  28. - MapNumberToGroupName                  (F217/08) #5
  29. - MapNumberToObject                     (F217/04) #4
  30. - MapObjectToNumber                     (F217/03) #3
  31. * OpenBindery                           (F217/45)
  32. * ReadPropertyValue                     (F217/3D)
  33. * RenameBinderyObject                   (F217/34)
  34. * ScanBinderyObject                     (F217/37)
  35. * ScanProperty                          (F217/3C)
  36. * VerifyBinderyObjectPassword           (F217/3F) Unencrypted Passwords.
  37. * VerifyEncrBinderyObjectPassword       (F217/4A) Encrypted passwords
  38. * WritePropertyValue                    (F217/3E)
  39.  
  40.   Secondary Functions:
  41.  
  42. * IsShellLoaded
  43. * IsUserLoggedOn
  44. * ExistsUser
  45. * GetRealUserName
  46. * IsGroupMember
  47. * AddUserToGroup
  48. * DeleteUserFromGroup
  49.  
  50. Notes: -Names of Objects & properties are automaticly converted to uppercase
  51.         by the above functions.
  52.        -Functions marked with a '*' are tested (with 3.11) and found correct.
  53.         (See example programs in XBIND.ZIP, e.g. SCANBIND,TSTBIND,BACKBIN).
  54.        -Functions marked with # are not implemented in this API.
  55.         #2: This call has been replaced by F217/40 ChangeBinderyObjectPassword.
  56.         #3: Replaced by F217/35 GetBinderyObjectID.
  57.         #4,#5: Replaced by F217/36 GetBinderyObjectName.
  58.         #5: replaced by F217/37 ScanBinderyObject and F217/3D ReadPropertyValue.
  59.  
  60. Related Functions in other units:
  61.  
  62.   GetConnectionInformation (nwConn)
  63.   GetObjectConnectionNumbers (nwConn)
  64.   LoginToFileServer (nwConn)
  65.   ScanObjectTrusteePaths (nwDir)
  66. }
  67.  
  68. CONST
  69.  { known object types: }
  70.   OT_WILD                        = -1;
  71.   OT_UNKNOWN                     = 0;
  72.   OT_USER                        = 1;
  73.   OT_USER_GROUP                  = 2;
  74.   OT_PRINT_QUEUE                 = 3;
  75.   OT_FILE_SERVER                 = 4;
  76.   OT_JOB_SERVER                  = 5;
  77.   OT_GATEWAY                     = 6;
  78.   OT_PRINT_SERVER                = 7;
  79.   OT_ARCHIVE_QUEUE               = 8;
  80.   OT_ARCHIVE_SERVER              = 9;
  81.   OT_JOB_QUEUE                   = $0A;
  82.   OT_ADMINISTRATION              = $0B;
  83.   OT_NAS_SNA_GATEWAY             = $21;
  84.   OT_REMOTE_BRIDGE_SERVER        = $24;
  85.   OT_ASYNC_BRIDGE_SERVER         = $26;   { note: # }
  86.   OT_TCPIP_GATEWAY               = $27;
  87.   OT_X25_BRIDGE                  = $28;   { # }
  88.   OT_X25_GATEWAY                 = $29;   { # EICON X25 Gateway }
  89.   OT_TIME_SYNCHRONIZATION_SERVER = $2D;
  90.   OT_ARCHIVE_SERVER_DYNAMIC_SAP  = $2E;
  91.   OT_DI3270_GATEWAY              = $45;   { # }
  92.   OT_ADVERTISING_PRINTSERVER     = $47;
  93.   OT_BTRIEVE_VAP                 = $4B;   { # Btrieve 5.0 Server; used to be $50 }
  94.   OT_BTRIEVE_5_SERVER            = $4B;   { # }
  95.   OT_NETWARE_SQL_SERVER          = $4C;   { # SQL VAP/NLM }
  96.   OT_XTREE_NETWORK               = $4D;   { # }
  97.   OT_BTRIEVE_4_SERVER            = $50;   { # Btrieve v.4.xx Server }
  98.   OT_PRINT_QUEUE_USER            = $53;
  99.   OT_EICON_ROUTER                = $58;   { # }
  100.   OT_ARCSERVE_30                 = $66;   { # }
  101.   OT_WANCOPY_UTILITY             = $72;   { # }
  102.   OT_TES_NETWARE_FOR_VMS         = $7A;   { # }
  103.   OT_EMERALD_BACKUP              = $92;   { # }
  104.   OT_NETWARE_ACCESS_SERVER       = $98;   { # }
  105.   OT_PORTABLE_NETWARE            = $9E;   { # }
  106.   OT_POWERCHUTE                  = $A1;   { # }
  107.   OT_COMPAQ_IDA_STATUS_MONITOR   = $AC;   { # }
  108.   OT_BINDERY                     = $0102; { # }
  109.   OT_ORACLE_DATABASE_SERVER      = $0103; { # }
  110.   OT_RSPCX_SERVER                = $0107; { # Rconsole }
  111.   OT_CSA_MUX                     = $0114; { # }
  112.   OT_CSA_LSA                     = $0115; { # }
  113.   OT_CSA_CM                      = $0116; { # }
  114.   OT_CSA_SMA                     = $0117; { # }
  115.   OT_CSA_DBA                     = $0118; { # }
  116.   OT_CSA_NMA                     = $0119; { # }
  117.   OT_CSA_SSA                     = $011A; { # }
  118.   OT_CSA_STATUS                  = $011B; { # }
  119.   OT_CSA_APPC                    = $011E; { # }
  120.   OT_CSA_TEST                    = $0126; { # }
  121.   OT_CSA_TRACE                   = $012A; { # }
  122.   OT_COMMUNICATIONS_EXEC         = $0130; { # }
  123.   OT_NNS_DOMAIN                  = $0133; { # }
  124.   OT_NNS_PROFILE                 = $0135; { # }
  125.   OT_NW386_PRINT_QUEUE           = $0137; { # }
  126.   OT_LANSPOOL_SERVER             = $0141; { # }
  127.   OT_COMPAQ_SNMP_AGENT           = $0174; { # }
  128.   OT_HP_LASERJET                 = $030C; { # }
  129.   OT_PC3M                        = $037E; { # ?Tape Backup?}
  130.   OT_ARCSERVE_40                 = $03C4; { # }
  131.   OT_NETWARE_SQL                 = $03DE; { # }
  132.   OT_SITE_LOCK_VRS_FILES         = $0429; { # }
  133.   OT_SITE_LOCK_CHECKS            = $0529; { # }
  134.   OT_SITE_LOCK                   = $0B29; { # , see $2380 }
  135.   OT_SITE_LOCK_APPLICATIONS      = $0C29; { # }
  136.   OT_SITE_LOCK_2                 = $2380; { # , see $0B29 }
  137.   OT_SITE_LOCK_SERVER            = $4808; { # }
  138.   OT_SITE_LOCK_USER              = $5555; { # }
  139.   OT_TAPEWARE                    = $6312; { # }
  140.   OT_RABBIT_GATEWAY              = $6F00; { # }
  141.   OT_TAPEWARE_AGENT              = $7F82; { # }
  142.  { object types are reserved upto $8000 }
  143.   OT_LANPORT                     =Word($8002); { * }
  144.   OT_INTEL_NETPORT               =Word($8002); { * }
  145.   OT_QUICK_NETWARE_MANAGEMENT    =Word($8888); { * }
  146.   OT_WORDPEFECT_NETWARE_VERSION  =Word($8888); { * }
  147.   OT_PEGASUS_MAIL                =Word($9009); { * }
  148.   OT_QNT_ACCESS_WS               =Word($B0EF); { * }
  149. { note #: These object type numbers are probably correct,
  150.           but there are no (Novell) standard names for these object types.
  151.        *: These object type numbers may be in use for other purposes by
  152.           other applications.                                              }
  153.  
  154.  { bindery security: }
  155.   BS_ANY_READ       = $00;
  156.   BS_LOGGED_READ    = $01;
  157.   BS_OBJECT_READ    = $02;
  158.   BS_SUPER_READ     = $03;
  159.   BS_BINDERY_READ   = $04;
  160.  
  161.   BS_ANY_WRITE      = $00;
  162.   BS_LOGGED_WRITE   = $10;
  163.   BS_OBJECT_WRITE   = $20;
  164.   BS_SUPER_WRITE    = $30;
  165.   BS_BINDERY_WRITE  = $40;
  166.  
  167. {property & object objFlag/propFlags Constants:}
  168.   BF_ITEM           = $00;
  169.   BF_SET            = $02;
  170.   BF_DYN_PROP       = $10; {1}
  171.   BF_STAT_PROP      = $00; {1}
  172.   { or BF_ITEM/SET with BF_xx_PROP to obtain propFlags }
  173.   BF_STAT_OBJ       = $00; {1}
  174.   BF_DYN_OBJ        = $01; {1}
  175.  
  176. { Note 1: not available in the NW interface for C }
  177.  
  178.  
  179. Type propertyType=Array[1..128] of Byte;
  180.  
  181. Var result:word;
  182.  
  183. {F217/32 [2.15c+] }
  184. Function CreateBinderyObject(objName:string; objType:Word;
  185.                              objFlaG, objSecurity :Byte   ):boolean;
  186. { Creates an object in the bindery.
  187.   objName: name of the new object (47 chars)
  188.   objType: object type number (own type number or OT_xxx constant)
  189.   objFlag: identifies an object as static (BF_STAT_OBJ (0))
  190.            or dynamic (BF_DYN_OBJ (1))
  191.            (dynamic objects are removed from the bindery when the server goes down)
  192.   objSecurity: high nibble: write privileges needed to modify this object
  193.                low  nibble: read privileges needed to access this object
  194.                (default: $31 Supervisor write/Logged read) }
  195.  
  196. {F217/33 [2.15c+] }
  197. Function DeleteBinderyObject( objName:String; objType:Word ):boolean;
  198. { deletes a bindery object and all asociated properties. }
  199.  
  200. {F217/34 [2.15c+]}
  201. Function RenameBinderyObject( objName,NewObjName :string; objType :word ):boolean;
  202. { This function allows the (supervisor-equivalent) user to rename an object,
  203.   given its' type and old name.                                              }
  204.  
  205. {F217/35 [2.15c+] }
  206. Function GetBinderyObjectID( objName:String; objType:word;
  207.                              Var object_ID:Longint       ):boolean;
  208. { returns the object ID of an object, given its type and name.       }
  209.  
  210. {F217/36 [2.15c+] }
  211. Function GetBinderyObjectName( object_Id:LongInt;
  212.                                Var objName:String; Var objType:word ):boolean;
  213. { returns the type and name of an object, given its four BYTE-id. }
  214.  
  215. {F217/37 [2.15c+]}
  216. Function ScanBinderyObject( SearchObjName: String;
  217.                             SearchObjType: Word;
  218.               {i/o:}    Var lastObjSeen  : Longint;
  219.               {out:}    Var RepName      : String;
  220.                         Var RepType      : Word;
  221.                         Var RepId        : LongInt;
  222.                         Var RepFlag      : Byte;
  223.                         Var RepSecurity  : Byte;
  224.                         Var RepHasProperties: Boolean
  225.                           ) :boolean;
  226. { This function scans the bindery and returns complete information about
  227.   a bindery object. It can be called iteratively.
  228.   -When called for the first time, supply -1 for lastObjSeen.
  229.   -Subsequent calls can then made (with lastObjSeen as an I/O parameter)
  230.    until error FCh: 'No Such Object' occurs.
  231.  
  232.   * as SearchObjName means all object names.
  233.   the SearchObjType is the object Type (OT_xxxxx). ( OT_WILD= -1: any type ) }
  234.  
  235. {F217/38 [2.15c+]}
  236. Function ChangeBinderyObjectSecurity(objName :String; objType :Word;
  237.                                      NewObjSecurity :Byte           ):boolean;
  238. { Changes the security of a Bindery object. This call is made successfully,
  239.   if the user is supervisor equivalent and the current security is unequal to
  240.   NetWare Read/ NetWare Write.                                              }
  241.  
  242. {F217/39 [2.15c+]}
  243. Function CreateProperty( objName:String; objType:Word;
  244.                     propertyName:String; propFlags,propSecurity:Byte ):boolean;
  245. { Creates a property to be associated with a bindery object.
  246.   Property flags tell whether a property is dynamic or static and whether
  247.   the property is defined as static or dynamic.  (see BF_xxx constants )    }
  248.  
  249. {F217/3A [2.15c+]}
  250. Function DeleteProperty( objName:String; objType:Word;
  251.                          propertyName:String          ):boolean;
  252. { Deletes a property from a bindery object.
  253.   The property field may contain wildcards.                                 }
  254.  
  255. {F217/3B [2.15c+] }
  256. Function ChangePropertySecurity( objName:String; objType:Word;
  257.                                 propName:String; newPropSecurity:Byte ):boolean;
  258. { The user must have read and write access to the property to make this call.
  259.   The call can't assign a greater security level than the security level of
  260.   the caller.                                                               }
  261.  
  262. {F217/3C [2.15c+]}
  263. Function ScanProperty( objName:String; objType:Word; searchPropName:String;
  264.             {i/o var:} Var SequenceNumber:LongInt;
  265.             { output:} Var propName:String;
  266.                        Var propFlags:Byte;
  267.                        Var propSecurity:Byte;
  268.                        Var propHasValue:Boolean;
  269.                        Var moreProperties:Boolean  ):boolean;
  270. { Sequence number should be -1 the first time this call is made.
  271.   The call can be reiterated (by supplying the returned Seq.#) until
  272.   moreProperties=FALSE or nwBindry.Result=NO_SUCH_PROPERTY.
  273.   searchPropName may contain wildcards;
  274.   If propHasValue=TRUE, the value can be read by calling ReadPropertyValue;
  275.   moreProperties=TRUE if more properties exist for this object.            }
  276.  
  277. {F217/3D [2.15c+]}
  278. Function ReadPropertyValue( objName:String; objType:Word;
  279.                             propName:String; segmentNumber:Word;
  280.                             Var propValue   : propertyType;
  281.                             Var moreSegments: Boolean;
  282.                             Var propFlags   : Byte              ):boolean;
  283. { Returns the value of a property associated with a Bindery object.     }
  284.  
  285. {F217/3E [2.15c+]}
  286. Function WritePropertyValue( objName:String; objType:Word;
  287.                    propName:String; segmentNbr: Byte; propValue:propertyType;
  288.                    moreSegments:Boolean                   ):boolean;
  289. { Changes the value of a (NON-SET) property associated with a Bindery object.
  290.   To write values to set-properties, use the AddBinderyObjectToSet call.
  291.   The user needs write access to the property to make this call.
  292.  
  293.   SegmentNBR should be set to 1 the first time this call is made. If there are
  294.   more segments, this value should be increased by EXACTLY 1.
  295.   If you know how many segments already exist, then you can set segmentNbr to
  296.   any segment in the range 1..'max_segment' and change that segment.
  297.  
  298.   The moreSegments flag should be set to TRUE if the current segment is NOT
  299.   the last segment to be written to. Setting this Flag to true will delete all
  300.   segments with a higher segmentnumber than the segment currently written to. }
  301.  
  302. {F217/3F [2.15c+]}
  303. FUNCTION VerifyBinderyObjectPassword
  304.           ( objName:string; objType:Word; password:string):boolean;
  305. { Verifies the accuracy of a password for a bindery object. }
  306. { for netware 3.xx remember to have previously (eg in the autoexec.ncf file )
  307.   set allow unencrypted passwords = on
  308.   on the console, otherwise this call always fails !
  309.   Note that intruder lockout status is affected by this call !
  310.   Netware security isn't that stupid....
  311.   Passwords need to be converted to upper case, NULL if there is no password. }
  312.  
  313. {F217/4A [2.15c+]}
  314. FUNCTION VerifyEncrBinderyObjectPassword
  315.           ( objName:string; objType:Word; password:string):boolean;
  316. { Verifies the accuracy of a password for a bindery object. }
  317. { Encrypts passwords. }
  318. { Passwords need to be converted to upper case, NULL if there is no password. }
  319.  
  320. {F217/40 [2.0/2.1/3.x] }
  321. Function ChangeBinderyObjectPassword(objName:String; objType:Word;
  322.                                      oldPassWord,newPassWord:String ):boolean;
  323. { Changes the password of a bindery object.
  324.   Allow unencrypted passwords must be ON!
  325.   Old Password can be NULL. To log into a file server, an object must have a
  326.   PASSWORD property. User must have read and write access to the bindery object. }
  327.  
  328. {F217/41 [2.15c+]}
  329. Function AddBinderyObjectToSet(objName:String; objType:Word;propName,
  330.                                memberName:String; memberType:Word ):boolean;
  331. { Adds a bindery object (member) to a property set.
  332.   user must have write access to the set property.                        }
  333.  
  334. {F217/42 [2.15c+]}
  335. Function DeleteBinderyObjectFromSet(objName:String; objType:Word;propName,
  336.                                     memberName:String; memberType:Word ):boolean;
  337. { Deletes a (member) bindery object from a property set.
  338.   user must have write access to the set property.                        }
  339.  
  340. {F217/43 [2.15c+]}
  341. Function IsBinderyObjectInSet(objName:String; objType:Word;propName,
  342.                               memberName:String; memberType:Word ):boolean;
  343. { Allows the programmer to check whether a bindery object is a member of a
  344.   set-property. memberName( of memberType) is the object to be searched for,
  345.   PropName (attached to the object with name objName (of objType))
  346.   is the property containing the set to be searched.
  347.   User must have read rights to the object and the property.
  348.   Ex: ('EVERYONE',OT_USER_GROUP,'GROUP_MEMBERS','SUPERVISOR',OT_USER)  }
  349.  
  350. {F217/44 [2.15c+]}
  351. Function CloseBindery:boolean;
  352. { Closes the bindery files so they can be backed up. (Supervisor only) }
  353.  
  354. {F217/45 [2.15c+]}
  355. Function OpenBindery:boolean;
  356. { This call must be used after the CloseBindery call. No other bindery
  357.   call will work while the bindery is closed.                          }
  358.  
  359. {F217/46 [2.15c+] }
  360. Function getBinderyAccessLevel( {out:} Var SecurityAccesslevel:byte;
  361.                                        Var ObjId:Longint          ): Boolean;
  362. { It returns the user's access level to the bindery.                      }
  363. { Often used as a quick way of determining the current users' object id   }
  364. { use the BS_xxxx constants to determine the exact rights of the user     }
  365.  
  366. {F217/17 [3.x]}
  367. FUNCTION GetEncryptionKey(VAR key : TencryptionKey): Boolean;
  368. { called by LoginToFileserver (nwConn), and VerifyBinderyObjectPassword,
  369.   ChangeBonderyObjectPassword (nwBindry) to get an encryption key for
  370.   the encryption function. }
  371.  
  372.  
  373. {************************** secondary functions: ****************************}
  374.  
  375. Function IsShellLoaded:boolean;
  376. Function IsUserLoggedOn:boolean;
  377. Function ExistsUser(userObjName:string):boolean;
  378. Function GetRealUserName(userObjname:string; Var realname:string):boolean;
  379. Function IsGroupMember(GroupName,UserObjName:String): Boolean;
  380. Function AddUserToGroup(userName,GroupName:String):boolean;
  381. Function DeleteUserFromGroup(userName,GroupName:String):boolean;
  382.  
  383. IMPLEMENTATION{=============================================================}
  384.  
  385. USES Dos;
  386.  
  387. Var UnitReqBuffer:array[1..576] of byte;
  388.     UnitReplyBuffer:array[1..576] of byte;
  389.     UnitRegs:registers;
  390.  
  391. Procedure F2SystemCall(subf:byte;req_size,rep_size:word);
  392. begin
  393. With UnitRegs
  394.  do begin
  395.     DS := Seg(UnitReqBuffer);  SI := Ofs(UnitReqBuffer);   CX := Req_size;
  396.     ES := Seg(UnitReplyBuffer);DI := Ofs(UnitReplyBuffer); DX := rep_size;
  397.     AH := $F2; AL := subf;
  398.     MSDOS(UnitRegs);
  399.     Result:=al;
  400.     end;
  401. end;
  402.  
  403.  
  404. {F217/17 [3.x]}
  405. FUNCTION GetEncryptionKey(VAR key : TencryptionKey): Boolean;
  406. Var req : RECORD
  407.           len : WORD;
  408.           func: BYTE;
  409.           END         ABSOLUTE UnitReqBuffer;
  410. BEGIN
  411. With req
  412.  do begin
  413.     len := 1;
  414.     func := $17;
  415.     end;
  416. F2Systemcall($17,sizeof(req),sizeof(key));
  417. Move(UnitReplyBuffer,key,8);
  418. GetEncryptionKey:=(Result=0);
  419. END;
  420.  
  421.  
  422. {F217/3F [2.15c+]}
  423. FUNCTION VerifyBinderyObjectPassword
  424.           ( objName:string;objType:Word; password : string):boolean;
  425. { Verifies the accuracy of a password for a bindery object. }
  426. { Passwords need to be converted to upper case, NULL if there is no password. }
  427. var  Request_buffer : record
  428.                       buffer_length : Word;
  429.                       subfunction   : byte;
  430.                       obj_type      : word; { hi-lo }
  431.                       _ObjectName   : string[48];
  432.                       _PassWord     : string[127];
  433.                       end                       ABSOLUTE UnitReqBuffer;
  434. begin
  435. With request_buffer
  436. do begin
  437.    buffer_length := SizeOf(request_buffer)-2;
  438.    subfunction :=$3F;
  439.    obj_type:=swap(objType); { force hi-lo }
  440.    UpString(objName);
  441.    UpString(password);
  442.    PStrCopy(_ObjectName,objName,48); _ObjectName[48]:=#0; UpString(_ObjectName);
  443.    PStrCopy(_PassWord,password,127); Upstring(_PassWord);
  444.   end;
  445. F2SystemCall($17,sizeof(request_buffer),0);
  446. VerifyBinderyObjectPassword:=(result=0);
  447. { possible resultcodes:
  448. $00    0      verification of object_name/password combination
  449. $96  150      Sever out of memory
  450. $C5  197      account disabled due to intrusion lockout
  451. $D6  214      unencrypted password calls not allowed on this v3+ server
  452. $F0  240      Wildcard not allowed
  453. $FB  251      no such property
  454. $FC  252      no such object_name on this server
  455. $FE  254      Server Bindery Locked
  456. $FF  255      Bindery failure (No such object or bad password)        }
  457. end;
  458.  
  459.  
  460. {F217/4A [3.x]}
  461. FUNCTION VerifyEncrBinderyObjectPassword(ObjName: String; ObjType: Word; PassWord: String): Boolean;
  462.  
  463.    FUNCTION VerifyEncrypted(ObjName : String; ObjType : Word; VAR key : TencryptionKey): Boolean;
  464.    VAR req : RECORD
  465.              BufLen  : Word;
  466.              _func   : Byte;
  467.              _key    : TencryptionKey;
  468.              _ObjType: Word;
  469.              _ObjName: String[48];
  470.              End                   ABSOLUTE UnitReqBuffer;
  471.    Begin
  472.    With req
  473.     do Begin
  474.        _func := $4A;
  475.        _key  := key;
  476.        _ObjType := Swap(objType);
  477.        PstrCopy(_ObjName,ObjName,48); UpString(_ObjName);
  478.        if ObjName[0]<#48
  479.         then _objName[0]:=objName[0]
  480.         else _objname[0]:=#48;
  481.        BufLen:=ord(_ObjName[0])+12;
  482.        End;
  483.    F2systemCall($17,sizeof(req),0);
  484.    VerifyEncrypted:=(result=0);
  485.    End;
  486.  
  487. VAR
  488.   key : TencryptionKey;
  489.   ObjId:LongInt;
  490.   _pw:string;
  491.   _lpw:Byte;
  492.  
  493. Begin
  494. UpString(password);
  495. _pw:=password;if _pw[0]>#127 Then _pw[0]:=#127;
  496. _lpw:=length(password);
  497. if _lpw=0 Then _pw:=#0;
  498.  
  499. IF GetEncryptionKey(key)
  500.  Then Begin
  501.       IF GetBinderyObjectId(objName,objType,ObjId)
  502.        Then Begin
  503.             EncryptPassword(objId,_pw,key);
  504.             VerifyEncrypted(ObjName, ObjType, key);
  505.             End;
  506.       End
  507.  Else VerifyBinderyObjectPassword(ObjName, ObjType, Password);
  508.  
  509. VerifyEncrBinderyObjectPassword := (result=0);
  510. End;
  511.  
  512.  
  513.  
  514. {F217/37 [2.15c+]}
  515. Function ScanBinderyObject( SearchObjName: String;
  516.                             SearchObjType: Word;
  517.               {i/o:}    Var lastObjSeen  : Longint;
  518.               {out:}    Var RepName      : String;
  519.                         Var RepType      : Word;
  520.                         Var RepId        : LongInt;
  521.                         Var RepFlag      : Byte;
  522.                         Var RepSecurity  : Byte;
  523.                         Var RepHasProperties: Boolean
  524.                           ) :boolean;
  525. { This function scans the bindery and returns complete information about
  526.   a bindery object. }
  527. var TempStr:string;
  528.     req : record
  529.           length          : word;
  530.           subfunction     : byte;
  531.           last_obj_id     : longint; {hi-lo}
  532.           search_obj_type : word;    {hi-lo}
  533.           search_obj_name : string[48];
  534.           end                           ABSOLUTE UnitReqBuffer;
  535.     rep : record
  536.           object_id   : longint; {hi-lo}
  537.           object_type : word;    {hi-lo}
  538.           object_name : array [1..48] of byte;
  539.           object_flag : byte;
  540.           security    : byte;
  541.           properties  : byte;
  542.           end                           ABSOLUTE UnitReplyBuffer;
  543.    count : integer;
  544. begin
  545. with req
  546. do begin
  547.    length := SizeOf(req)-2;
  548.    subfunction := $37;
  549.    last_obj_id := Lswap(lastObjseen);  { force hi-lo }
  550.    search_obj_type:= swap(Word(SearchObjType)); { force hi-lo }
  551.    PstrCopy(Search_obj_name,SearchObjName,48); Search_obj_Name[48]:=#0; UpString(Search_obj_name);
  552.    end;
  553. F2Systemcall($17,sizeOf(req),sizeOf(rep));
  554. With rep
  555. do begin
  556.    repFlag := object_flag;
  557.    repHasProperties := (properties>0);
  558.    repSecurity := security;
  559.    repType := swap(object_type); { force lo-hi }
  560.    repId := Lswap(object_id);    { force lo-hi }
  561.    lastObjSeen := repId;
  562.    ZStrCopy(repName,Object_Name,48);
  563.    end;
  564. scanBinderyObject:=(result=0);
  565. { Possible Resultcodes:
  566.   96h server out of memory; EFh Invalid Name; FCh No Such Object;
  567.   FEh Server Bindery Locked; FFh Bindery failure                  }
  568. end;
  569.  
  570.  
  571. {F217/3D [2.15c+]}
  572. Function ReadPropertyValue( objName:String; objType:Word;
  573.                             propName:String; segmentNumber:Word;
  574.                             Var propValue   : propertyType;
  575.                             Var moreSegments: Boolean;
  576.                             Var propFlags   : Byte              ):boolean;
  577. { Returns the value of a property associated with a Bindery object.     }
  578. var req : record
  579.           len         : word;
  580.           subfunction : byte;
  581.           _objType    : word;  { hi-lo }
  582.           _ObjName    : string[48];
  583.           _segNbr     : byte;
  584.           _propName   : string[15];
  585.           end                       ABSOLUTE UnitReqBuffer;
  586.    reply : record
  587.            _propValue : propertyType; {array [1..128] of byte}
  588.            _moreSegments : byte;
  589.            _propFlags : byte;
  590.            end                      ABSOLUTE UnitReplyBuffer;
  591. BEGIN
  592.  With req
  593.  do begin
  594.     len:=SizeOf(req)-2;
  595.     subfunction  := $3d;
  596.     _objType:=swap(objType); { force hi-lo }
  597.     _segNbr:=segmentNumber;
  598.     PStrCopy(_ObjName,objName,48); _ObjName[48]:=#0; UpString(_ObjName);
  599.     PStrCopy(_PropName,propName,15); UpString(_propName);
  600.     end;
  601.  With reply
  602.  do begin
  603.     _moreSegments := 1;
  604.     _propFlags := 0;
  605.     end;
  606. F2Systemcall($17,sizeof(req),sizeof(reply));
  607. if result=0
  608.  then begin
  609.       propValue:=reply._propValue;
  610.       moreSegments:=reply._moreSegments>0;
  611.       propFlags:=reply._propFlags;
  612.       end;
  613. ReadPropertyValue:=(result=0);
  614. { 96 server out of memory; EC no such segment; F0 wilcard not allowed;
  615.   f1 invalid bindery security; f9 no property read privileges;
  616.   fb no such property; fc no such object; FE Server Bindery Locked;
  617.   FF Bindery Failure.                                                 }
  618. end;
  619.  
  620.  
  621. {F217/36 [2.15c+] }
  622. Function GetBinderyObjectName( object_Id:LongInt;
  623.                                Var objName:String; Var objType:word ):boolean;
  624. { returns the type and name of an object, given its four BYTE-id. }
  625. Var Req :record
  626.          len:word;
  627.          subF:byte;
  628.          _objId:LongInt;  { hi-lo }
  629.          end                            ABSOLUTE UnitReqBuffer;
  630.    reply:record
  631.          _objId:LongInt;  { hi-lo }
  632.          _objType:word;   { hi-lo }
  633.          _objName:array[1..48] of Byte;
  634.          end                            ABSOLUTE UnitReplyBuffer;
  635. BEGIN
  636. WITH req
  637. do begin
  638.    len :=SizeOf(Req)-2;
  639.    SubF:=$36;
  640.    _objId:=Lswap(object_Id); { force hi-lo }
  641.    end;
  642. F2SystemCall($17,sizeOf(req),sizeOf(reply));
  643. IF result=0
  644.  then begin
  645.       ZstrCopy(objName,reply._objName,48);
  646.       objType:=swap(reply._objType); { force lo-hi }
  647.       end;
  648. GetBinderyObjectName:=(result=0);
  649. end;
  650.  
  651.  
  652. {F217/35 [2.15c+] }
  653. Function GetBinderyObjectID( objName:String; objType:word;
  654.                              Var object_ID:Longint       ):boolean;
  655. { returns the object ID of an object, given its type and name.       }
  656. Var req:record
  657.          len:word;
  658.          subF:Byte;
  659.          _objType:word;   { hi-lo }
  660.          _objName:string[48];
  661.          end                       ABSOLUTE UnitReqBuffer;
  662.     Reply:record
  663.          _objId:LongInt;  { hi-lo }
  664.          _objType:word;   { hi-lo }
  665.          _objName:array[1..48] of char;
  666.          end                       ABSOLUTE UnitReplyBuffer;
  667. BEGIN
  668. WITH req
  669. do begin
  670.    len :=SizeOf(Req)-2;
  671.    SubF:=$35;
  672.    _objType:=swap(objType); { force hi-lo }
  673.    PStrCopy(_objName,objName,48); _objName[48]:=#0;
  674.    UpString(_objName);
  675.    end;
  676. F2SystemCall($17,sizeOf(req),sizeOf(reply));
  677. IF result=0 then object_ID:=Lswap(reply._objId); { force lo-hi }
  678. GetBinderyObjectID:=(result=0);
  679. end;
  680.  
  681.  
  682. {F217/46 [2.15c+]}
  683. Function getBinderyAccessLevel(Var SecurityAccessLevel:byte;
  684.                                Var objId:Longint ):boolean;
  685. { It returns the user's access level to the bindery.                      }
  686. { Often used as a quick way of determining the current users' object id   }
  687. { use the BS_xxxx constants to determine the exact rights of the user     }
  688. Var req:record
  689.         len      :word;
  690.         subF     :byte;
  691.         end                         ABSOLUTE UnitReqBuffer;
  692.     reply:record
  693.           accLeveL:byte;
  694.           _objId:longInt;
  695.           fill:array[1..20] of byte;
  696.           end                       ABSOLUTE UnitReplyBuffer;
  697. BEGIN
  698. With req
  699.  do begin
  700.     subF:=$46;
  701.     len:=sizeOf(req)-2;
  702.     end;
  703. F2SystemCall($17,sizeOf(req),sizeOf(reply));
  704. If result=0
  705.  then with reply
  706.        do begin
  707.           SecurityAccessLevel:=accLevel;
  708.           objId:=Lswap(_objId);
  709.           end;
  710. GetBinderyAccessLevel:=(result=0);
  711. end;
  712.  
  713.  
  714.  
  715. {F217/45 [2.15c+]}
  716. Function OpenBindery:boolean;
  717. { This call must be used after the CloseBindery call. No other bindery
  718.   call will work while the bindery is closed.                          }
  719. Var req  :record
  720.           len:word;
  721.           subFunc:byte;
  722.           end            ABSOLUTE UnitReqBuffer;
  723. Begin
  724. WITH req
  725. do begin
  726.    len:=1;
  727.    subFunc:=$45;
  728.    end;
  729. F2SystemCall($17,sizeOf(req),0);
  730. OpenBindery:=(result=0)
  731. end;
  732.  
  733.  
  734. {F217/44 [2.15c+]}
  735. Function CloseBindery:boolean;
  736. { Closes the bindery files so they can be backed up. (Supervisor only) }
  737. Var req  :record
  738.           len:word;
  739.           subFunc:byte;
  740.           end           ABSOLUTE UnitReqBuffer;
  741. Begin
  742. WITH req
  743. do begin
  744.    len:=SizeOf(req)-2;
  745.    subFunc:=$44;
  746.    end;
  747. F2SystemCall($17,sizeOf(req),0);
  748. CloseBindery:=(result=0)
  749. end;
  750.  
  751.  
  752. {F217/32 [2.15c+] }
  753. Function CreateBinderyObject(objName:string; objType:Word;
  754.                              objFlaG, objSecurity :Byte   ):boolean;
  755. { Creates an object in the bindery.
  756.   objName: name of the new object (47 chars)
  757.   objType: object type number (own type number or OT_xxx constant)
  758.   objFlag: identifies an object as static (0) or dynamic (1)
  759.            (dynamic objects are removed from the bindery when the server goes down)
  760.   objSecurity: high nibble: write privileges needed to modify this object
  761.                low  nibble: read privileges needed to access this object
  762.                (default: $31 Supervisor write/Logged read) }
  763. Var req  :record
  764.           len          :word;
  765.           subFunc      :byte;
  766.           _objFlag     :Byte;
  767.           _objSecurity :Byte;
  768.           _objType     :word; { hi-lo }
  769.           _objName     :string[48]
  770.           end                        ABSOLUTE UnitReqBuffer;
  771. Begin
  772. WITH req
  773. do begin
  774.    len:=SizeOf(req)-2;
  775.    subFunc:=$32;
  776.    _objFlag:=objFlag;
  777.    _objSecurity:=objSecurity;
  778.    _objType:=swap(objType); { force hi-lo }
  779.    PStrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  780.   end;
  781. F2SystemCall($17,sizeof(req),0);
  782. CreateBinderyObject:=(result=0)
  783. { 96h server out of memory; EEh Object Already Exists; EFh Invalid Name
  784.   F1h invalid Bindery security; F5h no object create privileges
  785.   FEh Server Bindery Locked; FFh Bindery Failure                        }
  786. end;
  787.  
  788.  
  789.  
  790. {F217/33 [2.15c+] }
  791. Function DeleteBinderyObject( objName:String; objType:Word ):boolean;
  792. { deletes a bindery object and all asociated properties. }
  793. Var req  :record
  794.           len      :word;
  795.           subFunc  :byte;
  796.           _objType :Word; { hi-lo }
  797.           _objName :string[48];
  798.           end                   ABSOLUTE UnitReqBuffer;
  799. Begin
  800. WITH req
  801. do begin
  802.    len:=SizeOf(req)-2;
  803.    subFunc:=$33;
  804.    _objType:=swap(objType); { force hi-lo }
  805.    PStrCopy(_objName,objName,48); _objName[48]:=#48; UpString(_objName);
  806.    end;
  807. F2SystemCall($17,sizeOf(req),0);
  808. DeleteBinderyObject:=(result=0)
  809. { 96h Server out of memory; EFh Invalid name; F0h wildcard not allowed;
  810.   F4h No object delete privileges; FCh no such object
  811.   FEh Server Bindery Locked; FFh bindery failure                        }
  812. end;
  813.  
  814.  
  815. {F217/34 [2.15c+]}
  816. Function RenameBinderyObject( objName,NewObjName :string; objType :word ):boolean;
  817. { This function allows the (supervisor-equivalent) user to rename an object,
  818.   given its' type and old name.                                              }
  819. Var req  :record
  820.           len         :word;
  821.           subFunc     :byte;
  822.           _objType    :word; { hi-lo }
  823.           _objName    :string[48];
  824.           _NewObjName :string[48];
  825.           end                       ABSOLUTE UnitReqBuffer;
  826. Begin
  827. WITH req
  828. do begin
  829.    len:=SizeOf(req)-2;
  830.    subFunc:=$34;
  831.    _objType:=swap(objType); { force hi-lo }
  832.    PstrCopy(_objName,objName,48); _objName[48]:=#0; Upstring(_objName);
  833.    PstrCopy(_NewObjName,NewObjName,48); _NewObjName[48]:=#0; UpString(_NewObjName);
  834.    end;
  835. F2SystemCall($17,sizeOf(req),0);
  836. RenameBinderyObject:=(result=0)
  837. { 96h Server out of memory; EFh Invalid name; F0h wildcard not allowed;
  838.   F3h No object rename privileges; FCh no such object
  839.   FEh Server Bindery Locked; FFh bindery failure                        }
  840. end;
  841.  
  842.  
  843.  
  844. {F217/43 [2.15c+]}
  845. Function IsBinderyObjectInSet(objName:String; objType:Word;
  846.                  propName, memberName:String; memberType:Word ):boolean;
  847. { Allows the programmer to check whether a bindery object is a member of a
  848.   set-property. Objectname( of Objecttype) is the object to be searched for,
  849.   PropName (attached to the object with name memberName (of memberType))
  850.   is the property containing the set to be searched.
  851.   User must have read rights to the object and the property.
  852.   Ex: ('SUPERVISOR',OT_USER,'GROUP_MEMBERS','EVERYONE',OT_USER_GROUP)       }
  853. Var req  :record
  854.           len         :word;
  855.           subFunc     :byte;
  856.           _objType    :Word;       { hi-lo   }
  857.           _objName    :String[48]; { [48]=#0 }
  858.           _propName   :String[15];
  859.           _memObjType :Word;       { hi-lo   }
  860.           _memName    :String[48]; { [48]=#0 }
  861.           end                      ABSOLUTE UnitReqBuffer;
  862. Begin
  863. WITH req
  864. do begin
  865.    len:=SizeOf(req)-2;
  866.    subFunc:=$43;
  867.    _objType:=swap(objType); { force hi-lo }
  868.    PstrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  869.    PstrCopy(_propName,propName,15); UpString(_propName);
  870.    _memObjType:=swap(memberType); { force hi-lo }
  871.    PStrCopy(_memName,memberName,48); _memName[48]:=#0; UpString(_memName);
  872.    end;
  873. F2SystemCall($17,sizeOf(req),0);
  874. IsBinderyObjectInSet:=(result=0)
  875. { 96h Server out of memory; EA No Such member; EB Not Group Property
  876.   F0h wildcard not allowed; F9 No Property read privileges;
  877.   FCh no such object; FEh Server Bindery Locked; FFh bindery failure        }
  878. end;
  879.  
  880.  
  881.  
  882. {F217/41 [2.15c+]}
  883. Function AddBinderyObjectToSet(objName:String; objType:Word;
  884.                   propName, memberName:String; memberType:Word ):boolean;
  885. { Adds a bindery object to a property set.
  886.   user must have write access to the set property.                        }
  887. Var req  :record
  888.           len         :word;
  889.           subFunc     :byte;
  890.           _objType    :Word;       { hi-lo   }
  891.           _objName    :String[48]; { [48]=#0 }
  892.           _propName   :String[15];
  893.           _memObjType :Word;       { hi-lo   }
  894.           _memName    :String[48]; { [48]=#0 }
  895.           end                      ABSOLUTE UnitReqBuffer;
  896. Begin
  897. WITH req
  898. do begin
  899.    len:=SizeOf(req)-2;
  900.    subFunc:=$41;
  901.    _objType:=swap(objType); { force hi-lo }
  902.    PstrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  903.    PstrCopy(_propName,propName,15); UpString(_propName);
  904.    _memObjType:=swap(memberType); { force hi-lo }
  905.    PStrCopy(_memName,memberName,48); _memName[48]:=#0; UpString(_memName);
  906.    end;
  907. F2SystemCall($17,sizeOf(req),0);
  908. AddBinderyObjectToSet:=(result=0)
  909. { 96h Server out of memory; E9 Member already Exists; EB Not Group Property
  910.   F0h wildcard not allowed; F8 No Property write privileges;
  911.   FCh no such object; FEh Server Bindery Locked; FFh bindery failure        }
  912. end;
  913.  
  914.  
  915. {F217/42 [2.0/2.1/3.x]}
  916. Function DeleteBinderyObjectFromSet(objName:String; objType:Word;
  917.                        propName, memberName:String; memberType:Word ):boolean;
  918. { Deltes a bindery object from a property set.
  919.   user must have write access to the set property.                        }
  920. Var req  :record
  921.           len         :word;
  922.           subFunc     :byte;
  923.           _objType    :Word;       { hi-lo   }
  924.           _objName    :String[48]; { [48]=#0 }
  925.           _propName   :String[15];
  926.           _memObjType :Word;       { hi-lo   }
  927.           _memName    :String[48]; { [48]=#0 }
  928.           end                       ABSOLUTE UnitReqBuffer;
  929. Begin
  930. WITH req
  931. do begin
  932.    len:=SizeOf(req)-2;
  933.    subFunc:=$42;
  934.    _objType:=swap(objType); { force hi-lo }
  935.    PstrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  936.    PstrCopy(_propName,propName,15); UpString(_propName);
  937.    _memObjType:=swap(memberType); { force hi-lo }
  938.    PStrCopy(_memName,memberName,48); _memName[48]:=#0; UpString(_memName);
  939.    end;
  940. F2SystemCall($17,sizeOf(req),0);
  941. DeleteBinderyObjectFromSet:=(result=0)
  942. { 96h Server out of memory; EA No Such Member; EB Not Group Property
  943.   F0h wildcard not allowed; F8 No Property write privileges; FB No Such property;
  944.   FCh no such object; FEh Server Bindery Locked; FFh bindery failure        }
  945. end;
  946.  
  947.  
  948. {F217/38 [2.15c+]}
  949. Function ChangeBinderyObjectSecurity(objName :String; objType :Word;
  950.                                      NewObjSecurity :Byte           ):boolean;
  951. { Changes the security of a Bindery object. This call is made successfully,
  952.   if the user is supervisor equivalent and the current security is unequal to
  953.   NetWare Read/ NetWare Write.                                              }
  954. Var req  :record
  955.           len      :word;
  956.           subFunc  :byte;
  957.           _NobjSec :Byte;
  958.           _objType :Word; { hi-lo }
  959.           _objName :String[48]; { [48]=#0 }
  960.           end                     ABSOLUTE UnitReqBuffer;
  961. Begin
  962. WITH req
  963. do begin
  964.    len:=SizeOf(req)-2;
  965.    subFunc:=$38;
  966.    _NobjSec:=NewObjSecurity;
  967.    _objType:=swap(objType); { force hi-lo }
  968.    PstrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  969.    end;
  970. F2SystemCall($17,sizeOf(req),0);
  971. ChangeBinderyObjectSecurity:=(result=0)
  972. { Completion Codes:
  973.   96 Server out of memory; F0 Wildcard Not Allowed; F1 Invalid Bindery Security;
  974.   FC No Such Object; FE Server Bindery Locked; FF Bindery Failure.           }
  975. end;
  976.  
  977.  
  978.  
  979.  
  980. {F217/40 [2.0/2.1/3.x] }
  981. Function ChangeBinderyObjectPassword(objName:String; objType:Word;
  982.                                   oldPassWord,newPassWord:String ):boolean;
  983. { Changes the password of a bindery object.
  984.   Allow unencrypted passwords must be ON!
  985.   Old Password can be NULL. To log into a file server, an object must have a
  986.   PASSWORD property. User must have read and write access to the bindery object. }
  987. Var req  :record
  988.           len      :word;
  989.           subFunc  :byte;
  990.           _objType :Word;        { hi-lo }
  991.           _objName :String[48];  { [48]=#0 }
  992.           _oldPW   :String[128]; { wow! a password of 128 chars! }
  993.           _newPW   :String[128];
  994.           end                     ABSOLUTE UnitReqBuffer;
  995. Begin
  996. WITH req
  997. do begin
  998.    len:=SizeOf(req)-2;
  999.    subFunc:=$40;
  1000.    _objType:=swap(objType); { force hi-lo }
  1001.    PStrCopy(_objName,objName,48); _ObjName[48]:=#0; UpString(_objName);
  1002.    PStrCopy(_oldPW,oldPassWord,128); UpString(_oldPW);
  1003.    PStrCopy(_newPW,newPassWord,128); UpString(_newPW);
  1004.    end;
  1005. F2SystemCall($17,sizeOf(req),0);
  1006. ChangeBinderyObjectPassword:=(result=0)
  1007. { Completion Codes:
  1008.   96 Server Out Of Memory; F0 Wildcard Not Allowed; FB No Such Property;
  1009.   FC No Such Object; FE Server Bindery Locked; FF No Such Object *OR*
  1010.   No Password Associated With Object *OR* Old Password Invalid.           }
  1011. end;
  1012.  
  1013.  
  1014.  
  1015.  
  1016. {F217/39 [2.15c+]}
  1017. Function CreateProperty( objName:String; objType:Word;
  1018.                     propertyName:String; propFlags,propSecurity:Byte ):boolean;
  1019. { Creates a property to be associated with a bindery object.
  1020.   property flags tell whether a property is dynamic or static and whether
  1021.   the property is defined as static or dynamic.                            }
  1022. Var req  :record
  1023.           len       :word;
  1024.           subFunc   :byte;
  1025.           _objType  :Word;       { hi-lo }
  1026.           _objName  :String[48]; { [48]=#0 }
  1027.           _propFlags:Byte;
  1028.           _propSec  :Byte;
  1029.           _propName :String[15];
  1030.           end                      ABSOLUTE UnitReqBuffer;
  1031. Begin
  1032. WITH req
  1033. do begin
  1034.    len:=SizeOf(req)-2;
  1035.    subFunc:=$39;
  1036.    _objType:=swap(objType); { force hi-lo }
  1037.    PStrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  1038.    _propFlags:=propFlags;
  1039.    _propSec:=propSecurity;
  1040.    PStrCopy(_propName,propertyName,15); UpString(_propName);
  1041.    end;
  1042. F2SystemCall($17,sizeof(req),0);
  1043. CreateProperty:=(result=0)
  1044. { Completion Codes:
  1045.   96 Server Out Of Memory; ED Property already exists; EF Invalid Name;
  1046.   F0 Wildcard Not Allowed; F1 Invalid Bindery Security; F7 No Property Create Privileges;
  1047.   FC No Such Object; FE Server Bindery Locked; FF Bindery Failure           }
  1048. end;
  1049.  
  1050.  
  1051. {F217/3A [2.15c+]}
  1052. Function DeleteProperty( objName:String; objType:Word;
  1053.                          propertyName:String          ):boolean;
  1054. { Deletes a property from a bindery object.
  1055.   The property field may contain wildcards.                                 }
  1056. Var req  :record
  1057.           len       :word;
  1058.           subFunc   :byte;
  1059.           _objType  :Word;       { hi-lo }
  1060.           _objName  :String[48]; { [48]=#0 }
  1061.           _propName :String[15];
  1062.           end                    ABSOLUTE UnitReqBuffer;
  1063. Begin
  1064. WITH req
  1065. do begin
  1066.    len:=SizeOf(req)-2;
  1067.    subFunc:=$3A;
  1068.    _objType:=swap(objType); { force hi-lo }
  1069.    PStrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  1070.    PStrCopy(_propName,propertyName,15); UpString(_propName);
  1071.    end;
  1072. F2SystemCall($17,sizeOf(req),0);
  1073. DeleteProperty:=(result=0)
  1074. { Completion Codes:
  1075.   96 Server Out Of Memory; F0 Wildcard Not Allowed; F1 Invalid Bindery Security;
  1076.   F6 No property delete privileges; FB No Such property;
  1077.   FC No Such Object; FE Server Bindery Locked; FF Bindery Failure           }
  1078. end;
  1079.  
  1080.  
  1081. {F217/3C [2.15c+]}
  1082. Function ScanProperty( objName:String; objType:Word; searchPropName:String;
  1083.             {i/o var:} Var SequenceNumber:LongInt;
  1084.             { output:} Var propName:String;
  1085.                        Var propFlags:Byte;
  1086.                        Var propSecurity:Byte;
  1087.                        Var propHasValue:Boolean;
  1088.                        Var moreProperties:Boolean  ):boolean;
  1089. { Sequence number should be -1 the first time this call is made.
  1090.   The call can be reiterated (by supplying the returned Seq.#) until
  1091.   moreProperties=FALSE or nwBindry.Result=NO_SUCH_PROPERTY.
  1092.   searchPropName may contain wildcards;
  1093.   If propHasValue=TRUE, the value can be read by calling ReadPropertyValue;
  1094.   moreProperties=TRUE if more properties exist for this object.            }
  1095. Var req  :record
  1096.           len       :word;
  1097.           subFunc   :byte;
  1098.           _objType  :Word;    {hi-lo}
  1099.           _objName  :String[48];
  1100.           _SeqNbr   :LongInt; {hi-lo}
  1101.           _propName :String[15];
  1102.           end                    ABSOLUTE UnitReqBuffer;
  1103.     reply:record
  1104.           _propName :array[1..16] of Byte;
  1105.           _propFlags:Byte;
  1106.           _propSec  :Byte;
  1107.           _SeqNbr   :Longint; {hi-lo}
  1108.           _propHasValue:Byte;
  1109.           _moreProp :Byte;
  1110.           end                   ABSOLUTE UnitReplyBuffer;
  1111. Begin
  1112. WITH req
  1113. do begin
  1114.    len:=SizeOf(req)-2;
  1115.    subFunc:=$3C;
  1116.    _objType:=swap(objType); { force hi-lo }
  1117.    PStrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  1118.    _SeqNbr:=Lswap(SequenceNumber); { force hi-lo }
  1119.    PstrCopy(_propName,searchPropName,15); UpString(_propName);
  1120.    end;
  1121. F2SystemCall($17,sizeof(req),sizeof(reply));
  1122. With reply
  1123. do begin
  1124.    SequenceNumber:=Lswap(_SeqNbr); { force lo-hi }
  1125.    ZStrCopy(propName,_propName,15);
  1126.    propFlags:=_propFlags;
  1127.    propSecurity:=_propSec;
  1128.    propHasValue:=(_propHasValue>0);
  1129.    moreProperties:=(_moreProp>0);
  1130.    end;
  1131. ScanProperty:=(result=0)
  1132. { Completion Codes:
  1133.   96 Server Out Of Memory; F1 Invalid Bindery Security; FB No Such property;
  1134.   FC No Such Object; FE Server Bindery Locked; FF Bindery Failure           }
  1135. end;
  1136.  
  1137.  
  1138. {F217/3E [2.15c+]}
  1139. Function WritePropertyValue( objName:String; objType:Word;
  1140.                    propName:String; segmentNbr: Byte; propValue:propertyType;
  1141.                    moreSegments:Boolean                   ):boolean;
  1142. { Changes the value of a (NON-SET) property associated with a Bindery object.}
  1143. Var req  :record
  1144.           len         :word;
  1145.           subFunc     :byte;
  1146.           _objType    :Word; { hi-lo }
  1147.           _objName    :String[48];
  1148.           _segNbr     :Byte;
  1149.           _EraseRemainingSeg:Byte; { FF=true 00=false }
  1150.           _propName   :String[15];
  1151.           _propValSeg :propertyType;
  1152.           end                        ABSOLUTE UnitReqBuffer;
  1153. Begin
  1154. WITH req
  1155. do begin
  1156.    len:=SizeOf(req)-2;
  1157.    subFunc:=$3E;
  1158.    _objType:=swap(objType); { force hi-lo }
  1159.    PStrCopy(_objName,objName,48); _objName[48]:=#0; UpString(_objName);
  1160.    _segNbr:=segmentNbr;
  1161.    if moreSegments
  1162.      then _EraseRemainingSeg:=$00
  1163.      else _EraseRemainingSeg:=$FF;
  1164.    PstrCopy(_propName,propName,15); UpString(_propName);
  1165.    _propValSeg:=propValue;
  1166.    end;
  1167. F2SystemCall($17,sizeOf(req),0);
  1168. WritePropertyValue:=(result=0)
  1169. { Completion Codes:
  1170.   96 Server Out Of Memory; E8 Not Item Property; EC no such segment;
  1171.   F0 Wildcard Not Allowed; F1 Invalid Bindery Security;
  1172.   F8 No property write privileges; FB No Such property;
  1173.   FC No Such Object; FE Server Bindery Locked; FF Bindery Failure           }
  1174. end;
  1175.  
  1176. {F217/3B [2.15c+] }
  1177. Function ChangePropertySecurity( objName:String; objType:Word;
  1178.                                 propName:String; newPropSecurity:Byte ):boolean;
  1179. { The user must have read and write access to the property to make this call.
  1180.   The call can't assign a greater security level than the security level of
  1181.   the caller.                                                               }
  1182. Var req  :record
  1183.           len:word;
  1184.           subFunc:byte;
  1185.           _objType:Word; { hi-lo }
  1186.           _objName:String[48];
  1187.           _NewPropSec:Byte;
  1188.           _PropName:String[15];
  1189.           end                   ABSOLUTE UnitReqBuffer;
  1190. Begin
  1191. WITH req
  1192. do begin
  1193.    len:=SizeOf(req)-2;
  1194.    subFunc:=$3B;
  1195.    _objType:=swap(objType); { force hi-lo }
  1196.    PstrCopy(_objName,objName,48); _objName[48]:=#0; Upstring(_objName);
  1197.    _NewPropSec:=NewPropSecurity;
  1198.    PstrCopy(_propName,propName,15); Upstring(_propName);
  1199.    end;
  1200. F2SystemCall($17,sizeOf(req),0);
  1201. ChangePropertySecurity:=(result=0)
  1202. { Completion Codes:
  1203.   96 Server Out Of Memory; F0 Wildcard Not Allowed; F1 Invalid Bindery Security;
  1204.   FB No Such property;  FC No Such Object; FE Server Bindery Locked;
  1205.   FF Bindery Failure                                                         }
  1206. end;
  1207.  
  1208.  
  1209.  
  1210. {=======SECONDARY FUNCTIONS===================================================}
  1211.  
  1212.  
  1213.  
  1214. Function IsShellLoaded:boolean;
  1215. Var mask:byte;
  1216.     id:LongInt;
  1217. begin
  1218. IsShellLoaded:=( nwBindry.getBinderyAccessLevel(mask,id) and (id<>0));
  1219. end;
  1220.  
  1221.  
  1222. Function IsUserLoggedOn:boolean;
  1223. Var mask:byte;
  1224.     id:LongInt;
  1225.     objName:String;
  1226.     objType:word;
  1227. begin
  1228. IsUserLoggedOn:=( nwBindry.getBinderyAccessLevel(mask,id)
  1229.                   and (id<>0)
  1230.                   and nwBindry.GetBinderyObjectName(id,objName,objType)
  1231.                 )
  1232. end;
  1233.  
  1234.  
  1235. Function GetRealUserName(userObjName:string; Var realname:string):boolean;
  1236. Var propValue:propertyType;
  1237.     moreSeg:Boolean;
  1238.     w,propFlag:Byte;
  1239. begin
  1240. If ReadPropertyValue(userObjName,OT_USER,'IDENTIFICATION',1,propValue,moreSeg,propFlag)
  1241.  then begin
  1242.       ZStrCopy(realname,propValue,128);
  1243.       w:=1;
  1244.       While ((w<=128) and (realname[w]<>#0)) do inc(w);
  1245.       realName[0]:=chr(w);
  1246.       end
  1247.  else realname:='';
  1248. end;
  1249.  
  1250. Function GetUserObjectID:LongInt;
  1251. Var mask:byte;
  1252.     id:LongInt;
  1253. begin
  1254. if getBinderyAccessLevel(mask,id)
  1255.  then GetUserObjectID:=id
  1256.  else getUserObjectID:=-1;
  1257. { -1 : look at nwBindry.result for error number }
  1258. end;
  1259.  
  1260.  
  1261. Function ExistsUser(userObjName:string):boolean;
  1262. Var nam:string;
  1263.     typ:word;
  1264.     id:LongInt;
  1265.     f,s:byte;
  1266.     hasProp:boolean;
  1267.     lastObjSeen:LongInt;
  1268. begin
  1269. lastObjSeen:=-1;
  1270. ExistsUser:=scanBinderyObject(userObjName,OT_USER,lastObjSeen,nam,typ,id,f,s,hasProp);
  1271. end;
  1272.  
  1273. Function IsGroupMember( GroupName,UserObjName:String): Boolean;
  1274. begin
  1275. IsGroupMember:=IsBinderyObjectInSet(GroupName,OT_USER_GROUP,'GROUP_MEMBERS',
  1276.                                     UserObjName,OT_USER);
  1277. end;
  1278.  
  1279.  
  1280.  
  1281.  
  1282. Function AddUserToGroup(userName,GroupName:String):boolean;
  1283. begin
  1284. { first create the necessary properties. They may already exist. }
  1285.  
  1286. CreateProperty(userName,OT_USER,'GROUPS_I''M_IN',
  1287.                BF_SET,BS_SUPER_WRITE OR BS_LOGGED_READ);
  1288. IF (result<>$00) and (result<>$ED) { property already exists }
  1289. then begin AddUserToGroup:=false;exit end; { bindery failure / bad username}
  1290.  
  1291. CreateProperty(userName,OT_USER,'SECURITY_EQUALS',
  1292.                BF_SET,BS_SUPER_WRITE OR BS_LOGGED_READ);
  1293. IF (result<>$00) and (result<>$ED) { property already exists }
  1294. then begin AddUserToGroup:=false;exit end;
  1295.  
  1296. { The following construction seems a bit overdone, but it is needed to keep
  1297.   the bindery consistent. A user is either fully added to a group OR
  1298.   nothing happens, this way we ensure that a user is not 'patially added'
  1299.   to a group.
  1300.   If the user already is a member of the group, no error is returned. }
  1301. IF AddBinderyObjectToSet(Groupname,OT_USER_GROUP,'GROUP_MEMBERS',
  1302.                          userName,OT_USER)
  1303.  then begin
  1304.       IF AddBinderyObjectToSet(userName,OT_USER,'GROUPS_I''M_IN',
  1305.                                GroupName,OT_USER_GROUP)
  1306.        then begin
  1307.             IF AddBinderyObjectToSet(userName,OT_USER,'SECURITY_EQUALS',
  1308.                                      GroupName,OT_USER_GROUP)
  1309.              then begin
  1310.                   AddUserToGroup:=true;
  1311.                   exit;
  1312.                   end
  1313.              else begin { attempt to delete partially setup member }
  1314.                   DeleteBinderyObjectFromSet(Groupname,OT_USER_GROUP,'GROUP_MEMBERS',
  1315.                                              userName,OT_USER);
  1316.                   DeleteBinderyObjectFromSet(userName,OT_USER,'GROUPS_I''M_IN',
  1317.                                              GroupName,OT_USER_GROUP)
  1318.                   end
  1319.             end
  1320.        else begin
  1321.             DeleteBinderyObjectFromSet(Groupname,OT_USER_GROUP,'GROUP_MEMBERS',
  1322.                                        userName,OT_USER);
  1323.             end;
  1324.       end;
  1325. if result=$E9 then result:=$00; { $E9: user already a member of group }
  1326. AddUserToGroup:=(result=0);
  1327. { As all these called functions are in this unit, you can check nwBindry.result
  1328.   for the errorcode. }
  1329. { resultcodes: $FC user OR group object doesn't exist. }
  1330. end;
  1331.  
  1332.  
  1333.  
  1334.  
  1335. Function DeleteUserFromGroup(userName,GroupName:String):boolean;
  1336. begin
  1337. { The following construction seems a bit overdone, but it is needed to keep
  1338.   the bindery consistent. A user is either totally deleted from a group OR
  1339.   nothing happens, this way we ensure that a user is not 'patially deleted'
  1340.   from a group.
  1341.   If the user was not a member of the group, no error is returned. }
  1342. IF DeleteBinderyObjectFromSet(Groupname,OT_USER_GROUP,'GROUP_MEMBERS',
  1343.                               userName,OT_USER)
  1344.  then begin
  1345.       IF DeleteBinderyObjectFromSet(userName,OT_USER,'GROUPS_I''M_IN',
  1346.                                     GroupName,OT_USER_GROUP)
  1347.        then begin
  1348.             IF DeleteBinderyObjectFromSet(userName,OT_USER,'SECURITY_EQUALS',
  1349.                                           GroupName,OT_USER_GROUP)
  1350.              then begin
  1351.                   DeleteUserFromGroup:=True;
  1352.                   exit;
  1353.                   end
  1354.              else begin { attempt to repair partially deleted member }
  1355.                   AddBinderyObjectToSet(Groupname,OT_USER_GROUP,'GROUP_MEMBERS',
  1356.                                         userName,OT_USER);
  1357.                   AddBinderyObjectToSet(userName,OT_USER,'GROUPS_I''M_IN',
  1358.                                         GroupName,OT_USER_GROUP)
  1359.                   end
  1360.             end
  1361.        else AddBinderyObjectToSet(Groupname,OT_USER_GROUP,'GROUP_MEMBERS',
  1362.                                   userName,OT_USER);
  1363.       end;
  1364. if result=$EA then result:=0; { $EA: user obj NOT a member of group }
  1365. DeleteUserFromGroup:=false;
  1366. { As all these called functions are in this unit, you can check nwBindry.result
  1367.   for the errorcode. }
  1368. { Resultcodes: $FC user OR group object doesn't exist.   }
  1369. end;
  1370.  
  1371.  
  1372. end. { end of unit nwBindry }
  1373.  
  1374.